﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SES.CMS.BL;
using SES.CMS.DO;
using System.Data;


namespace SES.CMS.AdminCP
{
    public partial class BuildMenuAdmin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Functions.ddlDatabinder(ddlPage, MenuAdminsDO.MENUADMINID_FIELD, MenuAdminsDO.NAME_FIELD, new MenuAdminsBL().SelectGetByTop("", "len(Level)=10", ""));
            
            
        }
        protected void ddlPage_SelectedIndexChanged(object sender, EventArgs e)
        {
            int page = int.Parse(ddlPage.SelectedValue);
            MenuAdminsDO objMenu = new MenuAdminsDO();
            objMenu.MenuAdminID = page;
            objMenu = new MenuAdminsBL().Select(objMenu);
            txtLinkX.Text= objMenu.Link;
            }

       
       // }
        //protected void tlCategoryDataSource()
        //{
        //    int page = int.Parse(ddlPage.SelectedValue);
        //    if (page == 3)
        //        tlCategory.DataSource = new cmsCategoryBL().SelectAdmin(false);
        //    else if (page == 4)
        //        tlCategory.DataSource = new cmsCategoryBL().SelectAdmin(true);
        //    tlCategory.DataBind();
        //    tlCategory.ExpandToLevel(3);
        //}
        //protected void tlProductCategoryDataSource()
        //{
        //    tlProductCategory.DataSource = new cmsProductCategoryBL().SelectAll();
        //    tlProductCategory.DataBind();
        //    tlProductCategory.ExpandToLevel(3);
        //}
        //protected void tlCategory_StartNodeEditing(object sender, DevExpress.Web.ASPxTreeList.TreeListNodeEditingEventArgs e)
        //{

        //    int id = 0;
        //    if (int.TryParse(tlCategory.EditingNodeKey, out id))
        //    {
        //        //   Response.Redirect("Default.aspx?Page=ArticleCategory&CategoryID=" + id.ToString());
        //        int page = int.Parse(ddlPage.SelectedValue);
        //        if (page == 3)
        //            txtLinkX.Text = "/danh-muc-tin/" + Ultility.Change_AV(new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = id }).Title) + "-" + id.ToString();
        //        else if (page == 4)
        //            txtLinkX.Text = "/noi-dung/" + Ultility.Change_AV(new cmsCategoryBL().Select(new cmsCategoryDO { CategoryID = id }).Title) + "-" + id.ToString();
        //    }

        //    tlCategoryDataSource();
        //}
        //protected void tlProductCategory_StartNodeEditing(object sender, DevExpress.Web.ASPxTreeList.TreeListNodeEditingEventArgs e)
        //{

        //    int id = 0;
        //    if (int.TryParse(tlProductCategory.EditingNodeKey, out id))
        //    {
        //        txtLinkX.Text = "/danh-muc/" + Ultility.Change_AV(new cmsProductCategoryBL().Select(new cmsProductCategoryDO() { ProductCategoryID = id }).ProductCategoryTitle) + "-" + id.ToString();
        //    }

        //    tlProductCategoryDataSource();
        //}
        //protected void gvAtDataSource()
        //{
        //    gvAt.DataSource = new cmsArticleBL().SelectAdmin(int.Parse(cboCategory.SelectedValue));
        //    gvAt.DataBind();
        //}
        //protected void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    gvAtDataSource();
        //}
        //protected void gvAt_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    int ArticleID = int.Parse(gvAt.DataKeys[gvAt.SelectedIndex].Value.ToString());
        //    txtLinkX.Text = "/bai-viet/" + Ultility.Change_AV(new cmsArticleBL().Select(new cmsArticleDO { ArticleID = ArticleID }).Title) + "-" + ArticleID.ToString();
        //}
        //protected void gvAt_PageIndexChanging(object sender, GridViewPageEventArgs e)
        //{
        //    gvAt.PageIndex = e.NewPageIndex;
        //    gvAtDataSource();
        //}
        //public void bindToDropDown(DropDownList ddl)
        //{
        //    DataTable dtCate = new cmsCategoryBL().SelectDropDownAdmin();
        //    foreach (DataRow dr in dtCate.Rows)
        //    {
        //        if (dr["ParentID"].ToString().Equals("0"))
        //        {
        //            ListItem item = new ListItem();
        //            item.Value = dr["CategoryID"].ToString();
        //            item.Text = "+ " + dr["Title"].ToString();
        //            ddl.Items.Add(item);
        //            GetChildItems(dr["CategoryID"].ToString(), dtCate, ddl);
        //        }
        //    }
        //}

        //private void GetChildItems(string parentID, DataTable dtTemp, DropDownList ddl)
        //{
        //    foreach (DataRow dr in dtTemp.Rows)
        //    {
        //        if (dr["ParentID"].ToString().Equals(parentID))
        //        {
        //            ListItem listChild = new ListItem();
        //            listChild.Text = "-------" + dr["Title"].ToString();
        //            listChild.Value = dr["CategoryID"].ToString();
        //            listChild.Attributes.Add("style", "background:#f9f9f9;color:#648293;");
        //            ddl.Items.Add(listChild);
        //        }
        //    }
        //}

        //protected void ddlMenuAdmin_SelectedIndexChanged(object sender, EventArgs e)
        //{

        //}
    }
}